<template>
    <div class="app-container">
        <div>
            <el-input placeholder="请输入称重编号" v-model="queryParams.czbh" clearable style="width: 18%">
            </el-input>
            <el-button type="primary" @click="getList" icon="el-icon-searchsousuo">搜索</el-button>
            <!-- <el-button type="primary" @click="chumenzheng">出门证</el-button> -->
        </div>
        <div class="content">
            <el-table :data="tableData" border style="width: 100%; height: 100%" @row-dblclick="handleRowDblClick">
                <!-- <el-table-column prop="gid" label="编号" width="90px" sortable>
                </el-table-column> -->
                <el-table-column prop="ddbh" label="订单号" width="200px" sortable> </el-table-column>
                <el-table-column prop="czbh" label="称重编号" width="150px" sortable>
                </el-table-column>
                <el-table-column prop="kahao" label="卡号" width="150px" sortable>
                </el-table-column>
                <el-table-column prop="chehao" label="车号" width="150px" sortable> </el-table-column>
                <el-table-column prop="wlmc" label="物料名称" width="150px" sortable>
                </el-table-column>
                <el-table-column prop="mzsj" label="进场时间" width="150px" sortable>
                </el-table-column>
                <el-table-column prop="dbh" label="进场地磅" sortable>
                </el-table-column>
                <el-table-column prop="pzsj" label="出厂时间" width="150px" sortable>
                </el-table-column>
                <el-table-column prop="dbh2" label="出厂地磅" sortable>
                </el-table-column>
                <el-table-column prop="gbzt" label="过磅状态" sortable>
                </el-table-column>
                <el-table-column prop="yj" label="退车" sortable> </el-table-column>
                <el-table-column prop="sdDwx" label="内外销" sortable>
                </el-table-column>
                <el-table-column prop="sdBzwm" label="包装物名" sortable>
                </el-table-column>
                <el-table-column prop="fksj" label="发卡时间" sortable>
                </el-table-column>
            </el-table>

            <el-dialog title="详细信息处理" :visible.sync="dialogVisible" width="90%">
                <el-form label-width="100px" :inline="true">
                    <el-row :gutter="20">
                        <!-- 第一行 -->
                        <el-col :span="3">
                            <el-form-item label="车号">
                                <el-input v-model="selectedRow.chehao"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item label="供应商编号">
                                <el-input v-model="selectedRow.gsbh"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item label="供应商名称">
                                <el-input v-model="selectedRow.gsmc"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item label="公司编号">
                                <el-input v-model="selectedRow.khbh"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item label="公司名称">
                                <el-input v-model="selectedRow.khmc"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item label="物料编号">
                                <el-input v-model="selectedRow.wlbh"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item label="物料名称">
                                <el-input v-model="selectedRow.wlmc"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <!-- 第二行 -->
                        <el-col :span="3">
                            <el-form-item label="仓库编号">
                                <el-input v-model="selectedRow.ckbh"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item label="仓库名称">
                                <el-input v-model="selectedRow.ckmc"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item label="客户编号">
                                <el-input v-model="selectedRow.khbh"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item label="送达方">
                                <el-input v-model="selectedRow.khmc"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <!-- 第二行 -->
                        <el-col :span="3">
                            <el-form-item label="卡号">
                                <el-input v-model="selectedRow.kahao"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item label="临时车牌">
                                <el-input v-model="selectedRow.lscp"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item label="预发吨位">
                                <el-input v-model="selectedRow.ddwlsl"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item label="规格">
                                <el-input v-model="selectedRow.guige"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item label="过磅类型">
                                <el-input v-model="selectedRow.gblx"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item label="预置扣重">
                                <el-input v-model="selectedRow.yzkz"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item label="预置重量">
                                <el-input v-model="selectedRow.yzzl"></el-input>
                            </el-form-item>
                        </el-col>



                    </el-row>
                    <el-row :gutter="20">
                        <!-- 第二行 -->
                        <el-col :span="3">
                            <el-form-item label="小于200出场">
                                <el-checkbox v-model="selectedRow.ht_yccl_yc_kg" :true-label="1" :false-label="0">
                                </el-checkbox>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item label="重量浮动出场">
                                <el-checkbox v-model="selectedRow.ht_kgfdcc" :true-label="1" :false-label="0">
                                </el-checkbox>
                            </el-form-item>
                        </el-col>

                        <el-col :span="3">
                            <el-form-item label="吸潮标记">
                                <el-checkbox v-model="selectedRow.yc_jzcc" :true-label="1" :false-label="0">
                                </el-checkbox>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item label="超长车标记">
                                <el-checkbox v-model="selectedRow.yc_ccc" :true-label="1" :false-label="0">
                                </el-checkbox>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item label="退车重量超差">
                                <el-checkbox v-model="selectedRow.czqztc" :true-label="1" :false-label="0">
                                </el-checkbox>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item label="使用临时车牌">
                                <el-checkbox v-model="selectedRow.lscp_bj" :true-label="1" :false-label="0">
                                </el-checkbox>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-form>
                <!-- 按钮行 -->
                <span slot="footer" class="dialog-footer">
                    <el-row type="flex" justify="end">
                        <el-button type="primary" v-hasPermi="['system:merge:xiugai']"
                            @click="jibenxinxibaocun">保存</el-button>
                        <!-- <el-button type="primary" @click="fpxinxichuli">发票信息处理</el-button> -->
                        <el-button type="primary" v-hasPermi="['system:merge:buda']"
                            @click="piaojubuda">票据补打</el-button>
                        <!-- <el-button type="primary" @click="handleConfirm">数据返回化验</el-button> -->
                        <el-button type="primary" v-hasPermi="['system:merge:shanchu']"
                            @click="sanshujiqnchang">删除已进场或待进场</el-button>
                        <el-button type="primary" v-hasPermi="['system:merge:tuihui']"
                            @click="zhuangtaihuitui">过磅状态退回</el-button>
                        <el-button type="primary" v-hasPermi="['system:merge:tuiche']"
                            @click="tuiche">退车与反退车</el-button>
                        <el-button type="primary" v-hasPermi="['system:merge:fubang']"
                            @click="fubangquxiao">复磅标记取消</el-button>
                        <el-button type="primary" v-hasPermi="['system:merge:menjin']"
                            @click="menjinzhuangtaixiugai">门禁状态修改</el-button>
                        <!-- <el-button type="primary" @click="zhuanyunbiaojiann">转运标记与取消</el-button>
                        <el-button type="primary" @click="chexiangchang">车厢长</el-button> -->
                    </el-row>
                </span>
            </el-dialog>
            <el-dialog title="发票信息处理" :visible.sync="fapiaoVisible" width="90%">
                <el-form label-width="100px" :inline="true">
                    <el-row :gutter="20">
                        <!-- 第一行 -->
                        <el-col :span="5">
                            <el-form-item label="银行持卡人姓名:">
                                <el-input v-model="selectedRow.yhckrxm"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="5">
                            <el-form-item label="银行卡号:">
                                <el-input v-model="selectedRow.yhkh"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="5">
                            <el-form-item label="联系电话:">
                                <el-input v-model="selectedRow.lxdh"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="5">
                            <el-form-item label="发票编号:">
                                <el-input v-model="selectedRow.fpbh"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="5">
                            <el-form-item label="发票审核人:">
                                <el-input v-model="selectedRow.fpshr"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="5">
                            <el-form-item label="发票上传身份证号:">
                                <el-input v-model="selectedRow.fpscsfzh"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="5">
                            <el-form-item label="粮食性质(潮粮\干粮):">
                                <el-input v-model="selectedRow.orclgl"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row type="flex" justify="end">
                        <el-button type="primary" @click="fapiaobaocun">保存</el-button>
                    </el-row>
                </el-form>
            </el-dialog>
            <el-dialog title="三豪车厢长" :visible.sync="chexiangchangVisible" width="90%">
                <el-form label-width="100px" :inline="true">
                    <el-row :gutter="20">
                        <!-- 第一行 -->
                        <el-col :span="5">
                            <el-form-item label="车牌号:">
                                <el-input v-model="sanhao.车牌号码"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="5">
                            <el-form-item label="车厢长:">
                                <el-input v-model="sanhao.车厢长度"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-button type="primary" @click="chexiangchangtinajia">添加或修改</el-button>
                        <el-button type="primary" @click="chexiangchangquxiao">取消</el-button>
                    </el-row>
                </el-form>
            </el-dialog>
            <el-dialog title="票据补打" :visible.sync="piaojuVisible" width="50%">
                <el-form label-width="100px" :inline="true">
                    <el-row :gutter="20">
                        <!-- 第一行 -->
                        <el-row type="flex">
                            <el-button type="primary" @click="chumenzheng">出门证</el-button>
                            <el-button type="primary" @click="cg_meitan">磅单</el-button>
                            <!-- <el-button type="primary" @click="caiwuduihuan"
                >财务兑换票</el-button
              >
              <el-button type="primary" @click="bangdan">磅单</el-button>
              <el-button type="primary" @click="weibangdan">微磅单</el-button> -->
                        </el-row>
                    </el-row>
                </el-form>
            </el-dialog>
            <chumen ref="chumen" :formData="selectedRow"></chumen>
            <cg_meitan ref="cg_meitan" :formData="selectedRow"></cg_meitan>
        </div>
        <div class="pagination-container">
            <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
                :limit.sync="queryParams.pageSize" @pagination="getList" />
        </div>
    </div>
</template>

<script>
import {
    deletedaijinchang,
    modifyStatus,
    selectByCzbh,
    selectchexianghcang,
    selectyccl,
    updategbztbyczbh,
    updateguozhong,
    zhuanyunbiaoji,
} from "@/api/system/Fdongbei/yccl";
import { listMerge, getMerge, delMerge, addMerge, updateMergemenjin, updateMergegx, updateMergegbztth, updateMergeyj, updateMergefb } from "@/api/system/Fdongbei/merge";
import chumen from "../bangdan/chumenzhengdjhd.vue";

import cg_meitan from "../bangdan/cg_meitan.vue";

export default {
    components: {
        chumen,
        cg_meitan
    },
    data() {
        return {
            value: false,
            tableData: [],
            dialogVisible: false,
            fapiaoVisible: false,
            chexiangchangVisible: false,
            piaojuVisible: false,
            selectedRow: {},
            datatab: [],
            sanhao: {},
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                sql: "",
            },
            total: 0,
            form: {
            },
        };
    },
    created() {
        this.getList();
    },
    methods: {
        chumenzheng() {
            this.$refs.chumen.select();

        },
        cg_meitan() {
            this.$refs.cg_meitan.select();
            // this.$refs.cg_meitan.code();
        },
        getList() {
            this.$modal.loading("查询中。。。");
            listMerge(this.queryParams).then((response) => {
                this.tableData = response.rows;
                this.total = response.total;
                this.loading = false;
                this.$modal.closeLoading();
            });
        },
        jibenxinxibaocun() {
            updateMergegx(this.selectedRow).then((response) => {
                if (response.code == 200) {
                    this.$modal.alert("修改成功");
                    this.getList();
                } else {
                    this.$modal.alertWarning("修改失败");
                }
            });
        },
        //发票信息处理
        fpxinxichuli() {
            this.fapiaoVisible = true;
        },
        fapiaobaocun() {
            updateguozhong(this.selectedRow).then((response) => {
                if (response.data > 0) {
                    this.$modal.alert("修改成功");
                    this.getList();
                } else {
                    this.$modal.alertWarning("修改失败");
                }
            });
        },
        sanshujiqnchang() {
            const czbhs = this.selectedRow.czbh;
            this.$modal.confirm('是否确认删除多交货单编号为"' + czbhs + '"的数据项？').then(function () {
                return delMerge(czbhs);
            }).then(() => {
                this.dialogVisible = false;
                this.getList();
                this.$modal.msgSuccess("删除成功");
            }).catch(() => { });
        },
        // 退车
        tuiche() {
            const czbhs = this.selectedRow.yj;
            const select = this.selectedRow;
            this.$modal.confirm('该车辆状态为"' + czbhs + '"是否修改？').then(function () {
                return updateMergeyj(select);
            }).then(() => {
                this.dialogVisible = false;
                this.getList();
                this.$modal.msgSuccess("修改成功！");
            }).catch(() => { });
        },

        // 复磅取消
        fubangquxiao() {
            updateMergefb(this.selectedRow).then((response) => {
                if (response.code == 200) {
                    this.$modal.alert("复磅车辆取消成功!!");
                    this.getList();
                    this.dialogVisible = false;
                } else {
                    this.$modal.alertWarning("修改失败");
                }
            });
        },
        //门禁状态修改 updateMergemenjin
        menjinzhuangtaixiugai() {
            updateMergemenjin(this.selectedRow).then((response) => {
                if (response.code == 200) {
                    this.$modal.alert(response.msg);
                    this.getList();
                    this.dialogVisible = false;
                } else {
                    this.$modal.alertWarning("修改失败");
                }
            });
        },
        zhuangtaihuitui() {
            const select = this.selectedRow;
            this.$modal.confirm('此车状态为："' + this.selectedRow.gbzt + '"是否进行状态退回？').then(function () {
                return updateMergegbztth(select);
            }).then(() => {
                this.dialogVisible = false;
                this.getList();
                this.$modal.msgSuccess("修改成功");
            }).catch(() => { });
        },
        zhuanyunbiaojiann() {
            zhuanyunbiaoji({
                czbh: this.selectedRow.czbh,
                gbzt: this.selectedRow.gbzt,
            }).then((response) => {
                this.$modal.msg(response.msg);
                this.getList();
            });
        },
        handleRowDblClick(row, column, event) {
            getMerge(row.czbh).then((response) => {
                this.selectedRow = response.data;
                // 显示对话框
                this.dialogVisible = true;
            });
        },
        chexiangchang() {
            selectchexianghcang({ czbh: "DR2412190002" }).then((response) => {
                this.sanhao = response.data;
            });
            this.chexiangchangVisible = true;
        },
        chexiangchangquxiao() {
            this.chexiangchangVisible = false;
        },
        chexiangchangtinajia() { },
        handleConfirm() {
            // 处理确定按钮的逻辑
            this.dialogVisible = false;
            // 可以在这里添加其他处理逻辑
        },
        piaojubuda() {
            this.piaojuVisible = true;
        }
    },
};
</script>

<style scoped lang="scss">
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 90vh;
    /* 使容器至少占满整个视口高度 */
}

.content {
    flex: 1;
    /* 使主要内容区域占据尽可能多的空间 */
}

.pagination-container .el-pagination {
    width: 100%;
}

.pagination-container {
    display: flex;
    width: 78%;
    justify-content: center;
    /* 水平居中 */
    align-items: center;
    /* 垂直居中 */
    padding: 16px;
    /* 可选，根据需要调整间距 */
    background-color: #ffffff;
    /* 可选，根据需要调整背景色 */
}
</style>
